/*
 * FormularLinea.java
 *
 * Created on 15-oct-2008, 12:00:03
 */
 
package investigaciones_itm.LineasInvestigacion;

import com.sun.rave.faces.data.DefaultSelectItemsArray;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.AddRemove;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.Tab;
import com.sun.webui.jsf.component.TabSet;
import com.sun.webui.jsf.component.Upload;
import com.sun.webui.jsf.model.Option;
import com.sun.webui.jsf.model.UploadedFile;
import itm.exception.ArchivoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import investigaciones_itm.SessionBean1;
import investigaciones_itm.RequestBean1;
import investigaciones_itm.ApplicationBean1;
import investigaciones_itm.upload.Archivo;
import itm.bo.grupoInvestigacion.GrupoInvestigacionBO;
import itm.bo.lineaInvestigacion.LineaInvestigacionBO;
import itm.vo.file.ArchivoVO;
import itm.vo.grupoInvestigacion.GrupoInvestigacionVO;
import itm.vo.lineaInvestigacion.EstadoComplementoLineaInvVO;
import itm.vo.lineaInvestigacion.LineaInvestigacionVO;
import itm.vo.lineaInvestigacion.ParAcademicoVO;
import itm.vo.personas.PersonaVO;
import java.io.File;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlInputTextarea;
import javax.faces.component.html.HtmlMessages;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import static itm.constants.FileConstants.*;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Administrador
 */
public class FormularLinea extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }

    private Page page1 = new Page();
    
    public Page getPage1() {
        return page1;
    }
    
    public void setPage1(Page p) {
        this.page1 = p;
    }
    
    private Html html1 = new Html();
    
    public Html getHtml1() {
        return html1;
    }
    
    public void setHtml1(Html h) {
        this.html1 = h;
    }
    
    private Head head1 = new Head();
    
    public Head getHead1() {
        return head1;
    }
    
    public void setHead1(Head h) {
        this.head1 = h;
    }
    
    private Link link1 = new Link();
    
    public Link getLink1() {
        return link1;
    }
    
    public void setLink1(Link l) {
        this.link1 = l;
    }
    
    private Body body1 = new Body();
    
    public Body getBody1() {
        return body1;
    }
    
    public void setBody1(Body b) {
        this.body1 = b;
    }
    
    private Form form1 = new Form();
    
    public Form getForm1() {
        return form1;
    }
    
    public void setForm1(Form f) {
        this.form1 = f;
    }
    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }
    private TabSet tabSet1 = new TabSet();

    public TabSet getTabSet1() {
        return tabSet1;
    }

    public void setTabSet1(TabSet ts) {
        this.tabSet1 = ts;
    }
    private Tab tab1 = new Tab();

    public Tab getTab1() {
        return tab1;
    }

    public void setTab1(Tab t) {
        this.tab1 = t;
    }
    private PanelLayout layoutPanel1 = new PanelLayout();

    public PanelLayout getLayoutPanel1() {
        return layoutPanel1;
    }

    public void setLayoutPanel1(PanelLayout pl) {
        this.layoutPanel1 = pl;
    }
    private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel2() {
        return gridPanel2;
    }

    public void setGridPanel2(HtmlPanelGrid hpg) {
        this.gridPanel2 = hpg;
    }
    private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel3() {
        return gridPanel3;
    }

    public void setGridPanel3(HtmlPanelGrid hpg) {
        this.gridPanel3 = hpg;
    }
    private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel4() {
        return gridPanel4;
    }

    public void setGridPanel4(HtmlPanelGrid hpg) {
        this.gridPanel4 = hpg;
    }
    private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel5() {
        return gridPanel5;
    }

    public void setGridPanel5(HtmlPanelGrid hpg) {
        this.gridPanel5 = hpg;
    }
    private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel7() {
        return gridPanel7;
    }

    public void setGridPanel7(HtmlPanelGrid hpg) {
        this.gridPanel7 = hpg;
    }
    private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel8() {
        return gridPanel8;
    }

    public void setGridPanel8(HtmlPanelGrid hpg) {
        this.gridPanel8 = hpg;
    }
    private HtmlPanelGrid gridPanel10 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel10() {
        return gridPanel10;
    }

    public void setGridPanel10(HtmlPanelGrid hpg) {
        this.gridPanel10 = hpg;
    }
    private HtmlPanelGrid gridPanel11 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel11() {
        return gridPanel11;
    }

    public void setGridPanel11(HtmlPanelGrid hpg) {
        this.gridPanel11 = hpg;
    }
    private HtmlPanelGrid gridPanel16 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel16() {
        return gridPanel16;
    }

    public void setGridPanel16(HtmlPanelGrid hpg) {
        this.gridPanel16 = hpg;
    }
    private HtmlPanelGrid gridPanel17 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel17() {
        return gridPanel17;
    }

    public void setGridPanel17(HtmlPanelGrid hpg) {
        this.gridPanel17 = hpg;
    }
    private HtmlPanelGrid gridPanel22 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel22() {
        return gridPanel22;
    }

    public void setGridPanel22(HtmlPanelGrid hpg) {
        this.gridPanel22 = hpg;
    }
    private HtmlPanelGrid gridPanel23 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel23() {
        return gridPanel23;
    }

    public void setGridPanel23(HtmlPanelGrid hpg) {
        this.gridPanel23 = hpg;
    }
    private HtmlPanelGrid gridPanel25 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel25() {
        return gridPanel25;
    }

    public void setGridPanel25(HtmlPanelGrid hpg) {
        this.gridPanel25 = hpg;
    }
    private HtmlPanelGrid gridPanel26 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel26() {
        return gridPanel26;
    }

    public void setGridPanel26(HtmlPanelGrid hpg) {
        this.gridPanel26 = hpg;
    }
    private HtmlPanelGrid gridPanel28 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel28() {
        return gridPanel28;
    }

    public void setGridPanel28(HtmlPanelGrid hpg) {
        this.gridPanel28 = hpg;
    }
    private HtmlPanelGrid gridPanel29 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel29() {
        return gridPanel29;
    }

    public void setGridPanel29(HtmlPanelGrid hpg) {
        this.gridPanel29 = hpg;
    }
    private HtmlPanelGrid gridPanel31 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel31() {
        return gridPanel31;
    }

    public void setGridPanel31(HtmlPanelGrid hpg) {
        this.gridPanel31 = hpg;
    }
    private HtmlPanelGrid gridPanel32 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel32() {
        return gridPanel32;
    }

    public void setGridPanel32(HtmlPanelGrid hpg) {
        this.gridPanel32 = hpg;
    }
    private HtmlOutputText outputNombre = new HtmlOutputText();

    public HtmlOutputText getOutputNombre() {
        return outputNombre;
    }

    public void setOutputNombre(HtmlOutputText hot) {
        this.outputNombre = hot;
    }
    private HtmlOutputText outputJustificacion = new HtmlOutputText();

    public HtmlOutputText getOutputJustificacion() {
        return outputJustificacion;
    }

    public void setOutputJustificacion(HtmlOutputText hot) {
        this.outputJustificacion = hot;
    }
    private HtmlOutputText outputProyeccion = new HtmlOutputText();

    public HtmlOutputText getOutputProyeccion() {
        return outputProyeccion;
    }

    public void setOutputProyeccion(HtmlOutputText hot) {
        this.outputProyeccion = hot;
    }
    private HtmlOutputText outputPerspectiva = new HtmlOutputText();

    public HtmlOutputText getOutputPerspectiva() {
        return outputPerspectiva;
    }

    public void setOutputPerspectiva(HtmlOutputText hot) {
        this.outputPerspectiva = hot;
    }
    private HtmlOutputText outputPares = new HtmlOutputText();

    public HtmlOutputText getOutputPares() {
        return outputPares;
    }

    public void setOutputPares(HtmlOutputText hot) {
        this.outputPares = hot;
    }
    private HtmlOutputText outputGrupo = new HtmlOutputText();

    public HtmlOutputText getOutputGrupo() {
        return outputGrupo;
    }

    public void setOutputGrupo(HtmlOutputText hot) {
        this.outputGrupo = hot;
    }
    private HtmlOutputText outputFecha = new HtmlOutputText();

    public HtmlOutputText getOutputFecha() {
        return outputFecha;
    }

    public void setOutputFecha(HtmlOutputText hot) {
        this.outputFecha = hot;
    }
    private HtmlInputTextarea textNombre = new HtmlInputTextarea();

    public HtmlInputTextarea getTextNombre() {
        return textNombre;
    }

    public void setTextNombre(HtmlInputTextarea hit) {
        this.textNombre = hit;
    }
    private HtmlInputTextarea textJustificacion = new HtmlInputTextarea();

    public HtmlInputTextarea getTextJustificacion() {
        return textJustificacion;
    }

    public void setTextJustificacion(HtmlInputTextarea hit) {
        this.textJustificacion = hit;
    }
    private HtmlInputTextarea textProyeccion = new HtmlInputTextarea();

    public HtmlInputTextarea getTextProyeccion() {
        return textProyeccion;
    }

    public void setTextProyeccion(HtmlInputTextarea hit) {
        this.textProyeccion = hit;
    }
    private HtmlInputTextarea textPersEpist = new HtmlInputTextarea();

    public HtmlInputTextarea getTextPersEpist() {
        return textPersEpist;
    }

    public void setTextPersEpist(HtmlInputTextarea hit) {
        this.textPersEpist = hit;
    }
    private DefaultSelectItemsArray multiSelectListbox1DefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getMultiSelectListbox1DefaultItems() {
        return multiSelectListbox1DefaultItems;
    }

    public void setMultiSelectListbox1DefaultItems(DefaultSelectItemsArray dsia) {
        this.multiSelectListbox1DefaultItems = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems() {
        return listbox1DefaultItems;
    }

    public void setListbox1DefaultItems(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems = dsia;
    }
    private UISelectItems listbox1SelectItems = new UISelectItems();

    public UISelectItems getListbox1SelectItems() {
        return listbox1SelectItems;
    }

    public void setListbox1SelectItems(UISelectItems uisi) {
        this.listbox1SelectItems = uisi;
    }
    private Calendar calendarRegistro = new Calendar();

    public Calendar getCalendarRegistro() {
        return calendarRegistro;
    }

    public void setCalendarRegistro(Calendar c) {
        this.calendarRegistro = c;
    }
    private HtmlCommandButton botonGuardar = new HtmlCommandButton();

    public HtmlCommandButton getBotonGuardar() {
        return botonGuardar;
    }

    public void setBotonGuardar(HtmlCommandButton hcb) {
        this.botonGuardar = hcb;
    }
    private HtmlCommandButton button3 = new HtmlCommandButton();

    public HtmlCommandButton getButton3() {
        return button3;
    }

    public void setButton3(HtmlCommandButton hcb) {
        this.button3 = hcb;
    }
    private Tab tab2 = new Tab();

    public Tab getTab2() {
        return tab2;
    }

    public void setTab2(Tab t) {
        this.tab2 = t;
    }
    private PanelLayout layoutPanel2 = new PanelLayout();

    public PanelLayout getLayoutPanel2() {
        return layoutPanel2;
    }

    public void setLayoutPanel2(PanelLayout pl) {
        this.layoutPanel2 = pl;
    }
    private HtmlPanelGrid gridPanel35 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel35() {
        return gridPanel35;
    }

    public void setGridPanel35(HtmlPanelGrid hpg) {
        this.gridPanel35 = hpg;
    }
    private HtmlPanelGrid gridPanel37 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel37() {
        return gridPanel37;
    }

    public void setGridPanel37(HtmlPanelGrid hpg) {
        this.gridPanel37 = hpg;
    }
    private HtmlPanelGrid gridPanel38 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel38() {
        return gridPanel38;
    }

    public void setGridPanel38(HtmlPanelGrid hpg) {
        this.gridPanel38 = hpg;
    }
    private HtmlPanelGrid gridPanel39 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel39() {
        return gridPanel39;
    }

    public void setGridPanel39(HtmlPanelGrid hpg) {
        this.gridPanel39 = hpg;
    }
    private HtmlPanelGrid gridPanel40 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel40() {
        return gridPanel40;
    }

    public void setGridPanel40(HtmlPanelGrid hpg) {
        this.gridPanel40 = hpg;
    }
    private HtmlPanelGrid gridPanel41 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel41() {
        return gridPanel41;
    }

    public void setGridPanel41(HtmlPanelGrid hpg) {
        this.gridPanel41 = hpg;
    }
    private HtmlPanelGrid gridPanel42 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel42() {
        return gridPanel42;
    }

    public void setGridPanel42(HtmlPanelGrid hpg) {
        this.gridPanel42 = hpg;
    }
    private HtmlPanelGrid gridPanel43 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel43() {
        return gridPanel43;
    }

    public void setGridPanel43(HtmlPanelGrid hpg) {
        this.gridPanel43 = hpg;
    }
    private HtmlPanelGrid gridPanel44 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel44() {
        return gridPanel44;
    }

    public void setGridPanel44(HtmlPanelGrid hpg) {
        this.gridPanel44 = hpg;
    }
    private HtmlPanelGrid gridPanel45 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel45() {
        return gridPanel45;
    }

    public void setGridPanel45(HtmlPanelGrid hpg) {
        this.gridPanel45 = hpg;
    }
    private HtmlOutputText outputText1 = new HtmlOutputText();

    public HtmlOutputText getOutputText1() {
        return outputText1;
    }

    public void setOutputText1(HtmlOutputText hot) {
        this.outputText1 = hot;
    }
    private HtmlOutputText outputText2 = new HtmlOutputText();

    public HtmlOutputText getOutputText2() {
        return outputText2;
    }

    public void setOutputText2(HtmlOutputText hot) {
        this.outputText2 = hot;
    }
    private HtmlOutputText outputText3 = new HtmlOutputText();

    public HtmlOutputText getOutputText3() {
        return outputText3;
    }

    public void setOutputText3(HtmlOutputText hot) {
        this.outputText3 = hot;
    }
    private HtmlOutputText outputText4 = new HtmlOutputText();

    public HtmlOutputText getOutputText4() {
        return outputText4;
    }

    public void setOutputText4(HtmlOutputText hot) {
        this.outputText4 = hot;
    }
    private HtmlInputText textFieldIdLinea = new HtmlInputText();

    public HtmlInputText getTextFieldIdLinea() {
        return textFieldIdLinea;
    }

    public void setTextFieldIdLinea(HtmlInputText hit) {
        this.textFieldIdLinea = hit;
    }
    private HtmlInputText textFieldNombreArchivo = new HtmlInputText();

    public HtmlInputText getTextFieldNombreArchivo() {
        return textFieldNombreArchivo;
    }

    public void setTextFieldNombreArchivo(HtmlInputText hit) {
        this.textFieldNombreArchivo = hit;
    }
    private HtmlInputTextarea textAreaNombreLinea = new HtmlInputTextarea();

    public HtmlInputTextarea getTextAreaNombreLinea() {
        return textAreaNombreLinea;
    }

    public void setTextAreaNombreLinea(HtmlInputTextarea hit) {
        this.textAreaNombreLinea = hit;
    }
    private HtmlInputTextarea textAreaDescripcion = new HtmlInputTextarea();

    public HtmlInputTextarea getTextAreaDescripcion() {
        return textAreaDescripcion;
    }

    public void setTextAreaDescripcion(HtmlInputTextarea hit) {
        this.textAreaDescripcion = hit;
    }
    private HtmlPanelGrid gridPanel46 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel46() {
        return gridPanel46;
    }

    public void setGridPanel46(HtmlPanelGrid hpg) {
        this.gridPanel46 = hpg;
    }
    private HtmlPanelGrid gridPanel47 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel47() {
        return gridPanel47;
    }

    public void setGridPanel47(HtmlPanelGrid hpg) {
        this.gridPanel47 = hpg;
    }
    private HtmlPanelGrid gridPanel48 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel48() {
        return gridPanel48;
    }

    public void setGridPanel48(HtmlPanelGrid hpg) {
        this.gridPanel48 = hpg;
    }
    private HtmlPanelGrid gridPanel49 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel49() {
        return gridPanel49;
    }

    public void setGridPanel49(HtmlPanelGrid hpg) {
        this.gridPanel49 = hpg;
    }
    private HtmlPanelGrid gridPanel50 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel50() {
        return gridPanel50;
    }

    public void setGridPanel50(HtmlPanelGrid hpg) {
        this.gridPanel50 = hpg;
    }
    private HtmlPanelGrid gridPanel51 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel51() {
        return gridPanel51;
    }

    public void setGridPanel51(HtmlPanelGrid hpg) {
        this.gridPanel51 = hpg;
    }
    private Upload fileUploadLinea = new Upload();

    public Upload getFileUploadLinea() {
        return fileUploadLinea;
    }

    public void setFileUploadLinea(Upload u) {
        this.fileUploadLinea = u;
    }
    private HtmlCommandButton botonAdjuntar = new HtmlCommandButton();

    public HtmlCommandButton getBotonAdjuntar() {
        return botonAdjuntar;
    }

    public void setBotonAdjuntar(HtmlCommandButton hcb) {
        this.botonAdjuntar = hcb;
    }
    private HtmlOutputText outputText5 = new HtmlOutputText();

    public HtmlOutputText getOutputText5() {
        return outputText5;
    }

    public void setOutputText5(HtmlOutputText hot) {
        this.outputText5 = hot;
    }
    private HtmlOutputText outputText6 = new HtmlOutputText();

    public HtmlOutputText getOutputText6() {
        return outputText6;
    }

    public void setOutputText6(HtmlOutputText hot) {
        this.outputText6 = hot;
    }
    private HtmlInputText textFieldArchivo = new HtmlInputText();

    public HtmlInputText getTextFieldArchivo() {
        return textFieldArchivo;
    }

    public void setTextFieldArchivo(HtmlInputText hit) {
        this.textFieldArchivo = hit;
    }
    private HtmlInputText textFieldFecha = new HtmlInputText();

    public HtmlInputText getTextFieldFecha() {
        textFieldFecha = new HtmlInputText();
        java.util.Date fechaActual = new java.util.Date();
        fechaActual = new Date(fechaActual.getTime());
        textFieldFecha.setValue(fechaActual);
        return textFieldFecha;
    }

    public void setTextFieldFecha(HtmlInputText hit) {
        this.textFieldFecha = hit;
    }
    private HtmlPanelGrid gridPanel52 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel52() {
        return gridPanel52;
    }

    public void setGridPanel52(HtmlPanelGrid hpg) {
        this.gridPanel52 = hpg;
    }
    private HtmlPanelGrid gridPanel53 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel53() {
        return gridPanel53;
    }

    public void setGridPanel53(HtmlPanelGrid hpg) {
        this.gridPanel53 = hpg;
    }
    private HtmlCommandButton botonGuardar1 = new HtmlCommandButton();

    public HtmlCommandButton getBotonGuardar1() {
        return botonGuardar1;
    }

    public void setBotonGuardar1(HtmlCommandButton hcb) {
        this.botonGuardar1 = hcb;
    }
    private HtmlCommandButton botonCancelar = new HtmlCommandButton();

    public HtmlCommandButton getBotonCancelar() {
        return botonCancelar;
    }

    public void setBotonCancelar(HtmlCommandButton hcb) {
        this.botonCancelar = hcb;
    }
    private AddRemove addRemoveListParesAcademicos = new AddRemove();

    public AddRemove getAddRemoveListParesAcademicos() {
        return addRemoveListParesAcademicos;
    }

    public void setAddRemoveListParesAcademicos(AddRemove ar) {
        this.addRemoveListParesAcademicos = ar;
    }
    
    /** Holds value of property availableOptions. */
    private Option[] availableOptionsGrupos = null;
       
    /** Holds value of property selectedOptions. */
    private String[] selectedOptionsGrupos = null;

    public Option[] getAvailableOptionsGrupos() {
        String nombreGrupo="", grupoId="";
        GrupoInvestigacionBO grupoInvestigacionBO = new GrupoInvestigacionBO();
        List<GrupoInvestigacionVO> listaGrupo = new ArrayList<GrupoInvestigacionVO>();
        try{
            listaGrupo=grupoInvestigacionBO.listarGrupos();
            if(listaGrupo.size()!=0){
                availableOptionsGrupos = new Option[listaGrupo.size()];

                for (int i=0; i<listaGrupo.size();i++) {
                    idGrupo =listaGrupo.get(i).getIdGrupo();
                    grupoId = String.valueOf(idGrupo);
                    nombreGrupo= listaGrupo.get(i).getNombreGrupo();
                    availableOptionsGrupos[i]=new Option(grupoId, nombreGrupo);
                } // end for
            }else{
                availableOptionsGrupos = new Option[1];
                availableOptionsGrupos[0] = new Option("0", "Lista vacia");
            }
        }catch(Exception e){
            e.getStackTrace();
        }
        return availableOptionsGrupos;
    }

    public void setAvailableOptionsGrupos(Option[] availableOptionsGrupos) {
        this.availableOptionsGrupos = availableOptionsGrupos;
    }

    public String[] getSelectedOptionsGrupos() {
        return selectedOptionsGrupos;
    }

    public void setSelectedOptionsGrupos(String[] selectedOptionsGrupos) {
        this.selectedOptionsGrupos = selectedOptionsGrupos;
    }

    /*public Option[] getAvailableOptions() {        
        int idPar=0;
        String nombrePar="";
        lineaInvBO = new LineaInvestigacionBO();
        List<ParAcademicoVO> listaPares = new ArrayList<ParAcademicoVO>();
        try{
            listaPares=lineaInvBO.listarPersonaParAcademico();
            
            availableOptions = new Option[listaPares.size()];
            for (int i=0; i<listaPares.size();i++) {
                idPar =listaPares.get(i).getIdParAcademico();
                nombrePar= listaPares.get(i).getNombreParAcademico();
                availableOptions[i]=new Option(idPar, nombrePar);
            } // end for
        }catch(Exception e){
            e.getStackTrace();
        }
        return availableOptions;
    
    }*/
    private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel6() {
        return gridPanel6;
    }

    public void setGridPanel6(HtmlPanelGrid hpg) {
        this.gridPanel6 = hpg;
    }
    private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel9() {
        return gridPanel9;
    }

    public void setGridPanel9(HtmlPanelGrid hpg) {
        this.gridPanel9 = hpg;
    }
    private HtmlOutputText outputText7 = new HtmlOutputText();

    public HtmlOutputText getOutputText7() {
        return outputText7;
    }

    public void setOutputText7(HtmlOutputText hot) {
        this.outputText7 = hot;
    }
    private HtmlCommandButton buttonIrAnexo = new HtmlCommandButton();

    public HtmlCommandButton getButtonIrAnexo() {
        return buttonIrAnexo;
    }

    public void setButtonIrAnexo(HtmlCommandButton hcb) {
        this.buttonIrAnexo = hcb;
    }
    private HtmlMessages messageList1 = new HtmlMessages();

    public HtmlMessages getMessageList1() {
        return messageList1;
    }

    public void setMessageList1(HtmlMessages hm) {
        this.messageList1 = hm;
    }
    private HtmlMessages messageList2 = new HtmlMessages();

    public HtmlMessages getMessageList2() {
        return messageList2;
    }

    public void setMessageList2(HtmlMessages hm) {
        this.messageList2 = hm;
    }
    private HtmlCommandButton button1 = new HtmlCommandButton();

    public HtmlCommandButton getButton1() {
        return button1;
    }

    public void setButton1(HtmlCommandButton hcb) {
        this.button1 = hcb;
    }
    private Tab tab3 = new Tab();

    public Tab getTab3() {
        return tab3;
    }

    public void setTab3(Tab t) {
        this.tab3 = t;
    }
    private PanelLayout layoutPanel3 = new PanelLayout();

    public PanelLayout getLayoutPanel3() {
        return layoutPanel3;
    }

    public void setLayoutPanel3(PanelLayout pl) {
        this.layoutPanel3 = pl;
    }
    private HtmlPanelGrid gridPanel12 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel12() {
        return gridPanel12;
    }

    public void setGridPanel12(HtmlPanelGrid hpg) {
        this.gridPanel12 = hpg;
    }
    private HtmlPanelGrid gridPanel15 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel15() {
        return gridPanel15;
    }

    public void setGridPanel15(HtmlPanelGrid hpg) {
        this.gridPanel15 = hpg;
    }
    private HtmlPanelGrid gridPanel18 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel18() {
        return gridPanel18;
    }

    public void setGridPanel18(HtmlPanelGrid hpg) {
        this.gridPanel18 = hpg;
    }
    private HtmlPanelGrid gridPanel21 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel21() {
        return gridPanel21;
    }

    public void setGridPanel21(HtmlPanelGrid hpg) {
        this.gridPanel21 = hpg;
    }
    private HtmlMessages messageList3 = new HtmlMessages();

    public HtmlMessages getMessageList3() {
        return messageList3;
    }

    public void setMessageList3(HtmlMessages hm) {
        this.messageList3 = hm;
    }
    private HtmlPanelGrid gridPanel24 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel24() {
        return gridPanel24;
    }

    public void setGridPanel24(HtmlPanelGrid hpg) {
        this.gridPanel24 = hpg;
    }
    private HtmlPanelGrid gridPanel27 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel27() {
        return gridPanel27;
    }

    public void setGridPanel27(HtmlPanelGrid hpg) {
        this.gridPanel27 = hpg;
    }
    private HtmlPanelGrid gridPanel30 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel30() {
        return gridPanel30;
    }

    public void setGridPanel30(HtmlPanelGrid hpg) {
        this.gridPanel30 = hpg;
    }
    private HtmlPanelGrid gridPanel33 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel33() {
        return gridPanel33;
    }

    public void setGridPanel33(HtmlPanelGrid hpg) {
        this.gridPanel33 = hpg;
    }
    private HtmlPanelGrid gridPanel34 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel34() {
        return gridPanel34;
    }

    public void setGridPanel34(HtmlPanelGrid hpg) {
        this.gridPanel34 = hpg;
    }
    private HtmlPanelGrid gridPanel36 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel36() {
        return gridPanel36;
    }

    public void setGridPanel36(HtmlPanelGrid hpg) {
        this.gridPanel36 = hpg;
    }
    private HtmlPanelGrid gridPanel54 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel54() {
        return gridPanel54;
    }

    public void setGridPanel54(HtmlPanelGrid hpg) {
        this.gridPanel54 = hpg;
    }
    private HtmlPanelGrid gridPanel55 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel55() {
        return gridPanel55;
    }

    public void setGridPanel55(HtmlPanelGrid hpg) {
        this.gridPanel55 = hpg;
    }
    private HtmlOutputText outputText8 = new HtmlOutputText();

    public HtmlOutputText getOutputText8() {
        return outputText8;
    }

    public void setOutputText8(HtmlOutputText hot) {
        this.outputText8 = hot;
    }
    private HtmlOutputText outputText9 = new HtmlOutputText();

    public HtmlOutputText getOutputText9() {
        return outputText9;
    }

    public void setOutputText9(HtmlOutputText hot) {
        this.outputText9 = hot;
    }
    private HtmlInputText textFieldNombrePar = new HtmlInputText();

    public HtmlInputText getTextFieldNombrePar() {
        return textFieldNombrePar;
    }

    public void setTextFieldNombrePar(HtmlInputText hit) {
        this.textFieldNombrePar = hit;
    }
    private HtmlOutputText outputText10 = new HtmlOutputText();

    public HtmlOutputText getOutputText10() {
        return outputText10;
    }

    public void setOutputText10(HtmlOutputText hot) {
        this.outputText10 = hot;
    }
    private HtmlOutputText outputText11 = new HtmlOutputText();

    public HtmlOutputText getOutputText11() {
        return outputText11;
    }

    public void setOutputText11(HtmlOutputText hot) {
        this.outputText11 = hot;
    }
    private HtmlInputText textFieldIdLinea1 = new HtmlInputText();

    public HtmlInputText getTextFieldIdLinea1() {
        return textFieldIdLinea1;
    }

    public void setTextFieldIdLinea1(HtmlInputText hit) {
        this.textFieldIdLinea1 = hit;
    }
    private HtmlInputText textFieldIdPar = new HtmlInputText();

    public HtmlInputText getTextFieldIdPar() {
        return textFieldIdPar;
    }

    public void setTextFieldIdPar(HtmlInputText hit) {
        this.textFieldIdPar = hit;
    }
    private HtmlInputText textFieldAreaTrabajoPar = new HtmlInputText();

    public HtmlInputText getTextFieldAreaTrabajoPar() {
        return textFieldAreaTrabajoPar;
    }

    public void setTextFieldAreaTrabajoPar(HtmlInputText hit) {
        this.textFieldAreaTrabajoPar = hit;
    }
    private HtmlCommandButton buttonAgregarPares = new HtmlCommandButton();

    public HtmlCommandButton getButtonAgregarPares() {
        return buttonAgregarPares;
    }

    public void setButtonAgregarPares(HtmlCommandButton hcb) {
        this.buttonAgregarPares = hcb;
    }
    private HtmlCommandButton buttonVolver = new HtmlCommandButton();

    public HtmlCommandButton getButtonVolver() {
        return buttonVolver;
    }

    public void setButtonVolver(HtmlCommandButton hcb) {
        this.buttonVolver = hcb;
    }
    private HtmlOutputText outputText12 = new HtmlOutputText();

    public HtmlOutputText getOutputText12() {
        return outputText12;
    }

    public void setOutputText12(HtmlOutputText hot) {
        this.outputText12 = hot;
    }
    private HtmlOutputText outputText13 = new HtmlOutputText();

    public HtmlOutputText getOutputText13() {
        return outputText13;
    }

    public void setOutputText13(HtmlOutputText hot) {
        this.outputText13 = hot;
    }

    // </editor-fold>

    private HttpSession session;

    private static final String ID_SESSION_FORMULAR_LINEA = "formular.linea";

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public FormularLinea() {
        this.cargarVariablesSesion();
    }

    public void cargarVariablesSesion(){
        if(this.getSession().getAttribute(ID_SESSION_FORMULAR_LINEA+"optionsPersonas")!=null){
            this.setOptionsPersonas((Option[]) this.getSession().getAttribute(ID_SESSION_FORMULAR_LINEA+"optionsPersonas"));
        }
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here
        
        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("FormularLinea Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }
    
    private GrupoInvestigacionVO grupoInvVO;
    private PersonaVO personaVO;
    private ParAcademicoVO parAcademicoVO;
    private LineaInvestigacionVO lineaInvVO;
    private LineaInvestigacionBO lineaInvBO;
    private EstadoComplementoLineaInvVO estadoComplementoLineaInvVO = new EstadoComplementoLineaInvVO();
    private DropDown dropDownPersonas = new DropDown();
    private Option[] optionsPersonas;
    private ArchivoVO archivoVO;
    private String nombreLinea = "",  justificacion = "",  proyeccion = "",  resultadoGrupos = "",  persEpistemologica = "",  fereg = "",  nombrePar = "",  areaTrabajoPar = "";
    private int idGrupo = 0,  identificacionPar = 0;
    private Date fechaReg = null;
    private String[] grupos;

    public void cargarOptionsPersonas(){
        List<PersonaVO> list = new ArrayList<PersonaVO>();
        lineaInvBO = new LineaInvestigacionBO();
        try {
            list = lineaInvBO.obtenerParesAcademicos();
            if(list.size()!=0){
                optionsPersonas = new Option[list.size()+1];
                optionsPersonas[0] = new Option("0", "Seleccione Una Persona");
                for(int i=0;i<list.size();i++){
                    optionsPersonas[i+1] = new Option(list.get(i).getIdPersona(), list.get(i).getNombrePersona());
                }
            }else{
                optionsPersonas[0] = new Option("0", "No Hay personas");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            Logger.getLogger(ConsultarLinea.class.getName()).log(Level.SEVERE, null, ex);
            error("Error al Cargar las personas");
        }
    }

    public String botonGuardar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        int resultado = 0;
        try {
            grupoInvVO = new GrupoInvestigacionVO();
            lineaInvVO = new LineaInvestigacionVO();
            lineaInvBO = new LineaInvestigacionBO();
            estadoComplementoLineaInvVO = new EstadoComplementoLineaInvVO();
            nombreLinea = (String) textNombre.getValue();
            justificacion = (String) textJustificacion.getValue();
            proyeccion = (String) textProyeccion.getValue();

            grupos = selectedOptionsGrupos;
            this.getSession().setAttribute(ID_SESSION_FORMULAR_LINEA+"selectedOptionsGrupos", this.getSelectedOptionsGrupos());
            persEpistemologica = (String) textPersEpist.getValue();
            java.util.Date fechaRegistro = (java.util.Date) calendarRegistro.getValue();

            if (nombreLinea == null || nombreLinea.equals("")) {
                error("Por favor digite el nombre de la línea de investigación.");
                return null;
            } else if (justificacion == null || justificacion.equals("")) {
                error("Por favor digite la Justificación de la línea de investigación.");
                return null;
            } else if (proyeccion == null || proyeccion.equals("")) {
                error("Por favor digite la Proyección de la línea de investigación.");
                return null;
            } else if (persEpistemologica == null || persEpistemologica.equals("")) {
                error("Por favor digite la Perspectiva Epistemologica de la línea de investigación.");
                return null;
            } else if (grupos == null || grupos.length == 0) {
                error("Por favor seleccione los grupos de Investigación.");
                return null;
            } else if (fechaRegistro == null) {
                error("Por favor digite la fecha de formulación del línea de investigación.");
                return null;
            }
            fereg = calendarRegistro.getValue().toString();
            fechaReg = new Date(fechaRegistro.getTime());
            lineaInvVO.setNombreLinea(nombreLinea);
            lineaInvVO.setJustificacionLinea(justificacion);
            lineaInvVO.setPosibilidadesProyeccion(proyeccion);
            lineaInvVO.setPersEpistemologica(persEpistemologica);
            lineaInvVO.setFechaRegistro(fechaReg);
            estadoComplementoLineaInvVO.setIdEstado(1);
            resultado = lineaInvBO.guardarFormularLinea(lineaInvVO, estadoComplementoLineaInvVO);
            if (resultado == 0) {
                error("A ocurrido un error al ingresar los datos.");
            } else {
                resultadoGrupos = insertarGruposLinea(grupos, resultado);
                if (resultadoGrupos.equals("ingreso")) {
                    info("La línea de investigación se ha formulado correctamente.");
                    //tabSetPartEvt.setSelected(tabAnexo.getId().toString());
                    textFieldIdLinea.setValue(resultado);
                    textFieldIdLinea1.setValue(resultado);
                    textAreaNombreLinea.setValue(nombreLinea);
                    button1.setDisabled(false);
                    buttonIrAnexo.setDisabled(false);
                } else {
                    error("error al ingresar los pares.");
                    return null;
                }
            }
        } catch (Exception e) {
            error("Error al formular la Línea.");
        }
        return "OK";
    }
    
    private String insertarGruposLinea(String[] grupos, int idLinea) throws Exception {
        // Try Catch Exception
        // This clip shows how to create a try/catch
        // statement to handle possible exceptions
        String resultado = "";
        try {
            // TODO: Insert logic that may cause an exception
            // for example, performing database logic or file access                       
            for (int i = 0; i < grupos.length; i++) {
                parAcademicoVO = new ParAcademicoVO();
                lineaInvVO = new LineaInvestigacionVO();
                grupoInvVO = new GrupoInvestigacionVO();
                lineaInvBO = new LineaInvestigacionBO();
                idGrupo = Integer.parseInt(grupos[i]);
                grupoInvVO.setIdGrupo(idGrupo);
                lineaInvVO.setIdLinea(idLinea);
                resultado = lineaInvBO.insertarGruposLinea(lineaInvVO, grupoInvVO);
                if (!resultado.equals("ingreso")) {
                    error("Error al ingresar los pares academicos.");
                    return null;
                }
            }
        } catch (Exception e) {
            // print exception information in the server log
            error("error al ingresar los pares. " + e);
            log("Exception Message!!!", e);
        }
        return resultado;
    }

    public String botonAdjuntar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        UploadedFile uploadedFile = this.fileUploadLinea.getUploadedFile();
        Archivo archivo = new Archivo();
        if(uploadedFile != null){
        if (uploadedFile.getContentType().equals("application/pdf")) {
            try {
                ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
                String path = context.getRealPath("/") + PATH_UPLOAD_LINEAS_INV;
                nombreArchivo = textFieldNombreArchivo.getValue().toString();
                archivo.uploadFile(uploadedFile, nombreArchivo, path);
                textFieldArchivo.setValue(path + textFieldNombreArchivo.getValue().toString() + ".pdf");
            } catch (ArchivoException ex) {
                Logger.getLogger(FormularLinea.class.getName()).log(Level.SEVERE, null, ex);
                ex.printStackTrace();
                error("Error al adjunta el archivo");
            }
            
        } else {
            error("Solo se admiten archivos en formato PDF");
        }
         }else{
            error("El máximo tamaño permitido es de 10MB");
        }
        // Some browsers return complete path name, some don't
        // Make sure we only have the file name        
        // First, try forward slash
  /*      int index = uploadedFileName.lastIndexOf('/');
        String justFileName;
        if (index >= 0) {
            justFileName = uploadedFileName.substring(index + 1);
        } else {
            // Try backslash
            index = uploadedFileName.lastIndexOf('\\');
            if (index >= 0) {
                justFileName = uploadedFileName.substring(index + 1);
            } else {
                // No forward or back slashes
                justFileName = uploadedFileName;
            }
        }*/
        return null;
    }
    private String nombreArchivo = "",  descripcionArchivo = "",  rutaArchivo = "";
    private int idEvento = 0,  idLinea = 0;
    private Date fechaArchivo = null;

    public String botonGuardar1_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        int resultado = 0;
        try {
            lineaInvBO = new LineaInvestigacionBO();
            archivoVO = new ArchivoVO();
            idLinea = (Integer) textFieldIdLinea.getValue();
            nombreArchivo = (String) textFieldNombreArchivo.getValue();
            descripcionArchivo = (String) textAreaDescripcion.getValue();
            rutaArchivo = (String) textFieldArchivo.getValue();
            fechaArchivo = (Date) textFieldFecha.getValue();

            if (idLinea == 0) {
                error("no hay una Línea vinculada.");
                return null;
            } else if (nombreArchivo == null || nombreArchivo.equals("")) {
                error("Por favor digíte el nombre del del archivo.");
                return null;
            } else if (descripcionArchivo == null || descripcionArchivo.equals("")) {
                error("Por favor digite la descripción del archivo.");
                return null;
            } else if (rutaArchivo == null || rutaArchivo.equals("")) {
                error("No se ha adjuntado el archivo.");
                return null;
            } else if (fechaArchivo == null) {
                error("Fallo al obtener la fecha.");
                return null;
            }
            archivoVO.setIdModulo(idLinea);
            archivoVO.setNombreArchivo(nombreArchivo);
            archivoVO.setDescripcion(descripcionArchivo);
            archivoVO.setRutaArchivo(rutaArchivo);
            archivoVO.setFechaArchivo(fechaArchivo);
            resultado = lineaInvBO.guardarArchivoLinea(archivoVO);

            if (resultado == 0) {
                error("Error al guardar el anexo");
            } else {
                info("El archivo se guardo correctamente");
                textFieldNombreArchivo.setValue("");
                textAreaDescripcion.setValue("");
                textFieldArchivo.setValue("");
                textFieldFecha.setValue("");
            }
        } catch (Exception e) {
            error("Error al guardar el anexo" + e);
            e.getStackTrace();
        }
        return null;
    }
    
    public String buttonAgregarPares_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        int resultado = 0;
        int idPar = 0;
        try {
            // TODO: Insert logic that may cause an exception
            // for example, performing database logic or file access    
            parAcademicoVO = new ParAcademicoVO();
            lineaInvVO = new LineaInvestigacionVO();
            lineaInvBO = new LineaInvestigacionBO();

            idLinea = (Integer) textFieldIdLinea.getValue();
            nombrePar = (String) textFieldNombrePar.getValue();
            String parId = (String) textFieldIdPar.getValue();
            areaTrabajoPar = (String) textFieldAreaTrabajoPar.getValue();

            if (nombrePar == null || nombrePar.equals("")) {
                error("Por favor digite el nombre del par academico.");
                return null;
            } else if (esNumero(parId) == false) {
                error("Por favor digite la identificación del par academico.");
                return null;
            } else if (areaTrabajoPar == null || areaTrabajoPar.equals("")) {
                error("Por favor digite el area de trabajo del par academico.");
                return null;
            }

            lineaInvVO.setIdLinea(idLinea);
            parAcademicoVO.setNombreParAcademico(nombrePar);
            parAcademicoVO.setIdParAcademico(Integer.parseInt(parId));
            parAcademicoVO.setAreaTrabajoPar(areaTrabajoPar);
            lineaInvBO.insertarParesAcademicos(parAcademicoVO, lineaInvVO);
                   
                info("El par academico se ingresó correctamente");
                textFieldNombrePar.setValue("");
                textFieldIdPar.setValue("");
                textFieldAreaTrabajoPar.setValue("");
            

        } catch (Exception e) {
            // print exception information in the server log
            error("error al ingresar los pares. ");
            log("Exception Message!!!", e);
        }
        return null;
    }
    
    private static boolean esNumero(String cadena){
        try {
		Integer.parseInt(cadena);
		return true;
	} catch (NumberFormatException nfe){
		return false;
	}
    }

    public String buttonIrAnexo_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        tabSet1.setSelected(tab2.getId().toString());
        return null;
    }

    public String botonCancelar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        if(this.getSession().getAttribute(ID_SESSION_FORMULAR_LINEA+"selectedOptionsGrupos")!=null){
            this.setSelectedOptionsGrupos((String[]) this.getSession().getAttribute(ID_SESSION_FORMULAR_LINEA+"selectedOptionsGrupos"));
        }
        tabSet1.setSelected(tab1.getId().toString());
        return null;
    }

    public String button1_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        this.cargarOptionsPersonas();
        this.getSession().setAttribute(ID_SESSION_FORMULAR_LINEA+"optionsPersonas", this.getOptionsPersonas());
        tabSet1.setSelected(tab3.getId().toString());
        return null;
    }

     public String actionDropDownPersonas(ValueChangeEvent vce){
        if(!dropDownPersonas.getValue().toString().equals("0")){
        this.textFieldIdPar.setValue(dropDownPersonas.getValue().toString());
        for(int i=0;i<optionsPersonas.length;i++){
            if(dropDownPersonas.getValue().equals(optionsPersonas[i].getValue())){
                this.textFieldNombrePar.setValue(optionsPersonas[i].getLabel());
            }
        }
        }else{
            this.textFieldIdPar.setValue("");
            this.textFieldNombrePar.setValue("");
        }
        return null;
    }

    public String buttonVolver_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        if(this.getSession().getAttribute(ID_SESSION_FORMULAR_LINEA+"selectedOptionsGrupos")!=null){
            this.setSelectedOptionsGrupos((String[]) this.getSession().getAttribute(ID_SESSION_FORMULAR_LINEA+"selectedOptionsGrupos"));
        }
        tabSet1.setSelected(tab1.getId().toString());
        return null;
    }

    public HttpSession getSession() {
        return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
    }

    public void setSession(HttpSession session) {
        this.session = session;
    }

    public DropDown getDropDownPersonas() {
        return dropDownPersonas;
    }

    public void setDropDownPersonas(DropDown dropDownPersonas) {
        this.dropDownPersonas = dropDownPersonas;
    }

    public Option[] getOptionsPersonas() {
        return optionsPersonas;
    }

    public void setOptionsPersonas(Option[] optionsPersonas) {
        this.optionsPersonas = optionsPersonas;
    }

    

    
}

